//
//  MarrySpeechSubViewController.m
//  BaseProject
//
//  Created by 王洋 on 2020/9/14.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "XLPageViewController.h"
#import "TT_WebviewController.h"

#import "MarrySpeechSubViewController.h"

@interface MarrySpeechSubViewController ()
<XLPageViewControllerDelegate,
XLPageViewControllerDataSrouce>

@property (nonatomic, strong) XLPageViewController *pageViewController;




@end

@implementation MarrySpeechSubViewController

- (instancetype)initWithType:(MarrySpeechSubType)type {
    
        self = [super init];
        
        if (self) {
            self.type = type;
        }
        return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    [self initPageViewController];
}

- (void)initPageViewController {
    
    XLPageViewControllerConfig *config = [XLPageViewControllerConfig defaultConfig];
    config.shadowLineColor = UIColorHex(0xff4242);
    config.titleSelectedFont = [UIFont boldSystemFontOfSize:14];
    config.titleNormalFont = [UIFont systemFontOfSize:14];
    config.titleViewAlignment = XLPageTitleViewAlignmentCenter;
    config.separatorLineHidden = true;
    config.shadowLineAnimationType = XLPageShadowLineAnimationTypeZoom;
    config.shadowLineWidth = 20;
    config.titleSpace = 20;
    
    self.pageViewController = [[XLPageViewController alloc] initWithConfig:config];
    self.pageViewController.view.frame = self.view.bounds;
    self.pageViewController.delegate = self;
    self.pageViewController.dataSource = self;
    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];
}

#pragma mark -
#pragma mark TableViewDelegate&DataSource
- (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index {
    
    TT_WebviewController *vc = [[TT_WebviewController alloc] init];
    
    NSInteger urlIndex = index + 1;
    NSString *htmlUrl = @"";
    switch (self.type) {
        case MarrySpeechSubType_xinlang:{
            htmlUrl = [NSString
                       stringWithFormat:@"%@/makeSpeech?type=%@&id=%02ld", BA_GlobalH5_Domain,@"bridegroomman",(long)urlIndex];
        } break;
        case MarrySpeechSubType_xinniang:{
            htmlUrl = [NSString
                       stringWithFormat:@"%@/makeSpeech?type=%@&id=%02ld", BA_GlobalH5_Domain,@"bridegroomwoman",(long)urlIndex];
        } break;
        case MarrySpeechSubType_fuqin:{
            htmlUrl = [NSString
                       stringWithFormat:@"%@/makeSpeech?type=%@&id=%02ld", BA_GlobalH5_Domain,@"father",(long)urlIndex];
        } break;
        case MarrySpeechSubType_muqin:{
            htmlUrl = [NSString
                       stringWithFormat:@"%@/makeSpeech?type=%@&id=%02ld", BA_GlobalH5_Domain,@"mother",(long)urlIndex];
        } break;
        case MarrySpeechSubType_banlang:{
            htmlUrl = [NSString
                       stringWithFormat:@"%@/makeSpeech?type=%@&id=%02ld", BA_GlobalH5_Domain,@"groomsman",(long)urlIndex];
        } break;
        case MarrySpeechSubType_banniang:{
            htmlUrl = [NSString
                       stringWithFormat:@"%@/makeSpeech?type=%@&id=%02ld", BA_GlobalH5_Domain,@"groomswoman",(long)urlIndex];
        } break;
        default:
            break;
    }
    vc.webUrl = htmlUrl;
    
    return vc;
}

- (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index {
    return [NSString stringWithFormat:@"模板%ld",index+1];

}

- (NSInteger)pageViewControllerNumberOfPage {
    
    switch (self.type) {
        case MarrySpeechSubType_xinlang:{
            
        } break;
        case MarrySpeechSubType_xinniang:{
            
        } break;
        case MarrySpeechSubType_fuqin:{
            
        } break;
        case MarrySpeechSubType_muqin:{
            
        } break;
        case MarrySpeechSubType_banlang:{
            
        } break;
        case MarrySpeechSubType_banniang:{
            
        } break;
        default:
            break;
    }
    return 8;
}


@end
